The nasty neighbor effect in humans

Like other group-living species, humans often cooperate more with an in-group member than with out-group members and strangers. Greater in-group favoritism should imply that people also compete less with in-group members than with out-group members and strangers. However, in situations where people could invest to take other’s resources and invest to protect against exploitation, we observed the opposite. Akin to what in other species is known as the “nasty neighbor effect,” people invested more when facing an in-group rather than out-group member or stranger across 51 nations, in different communities in Kenya, and in representative samples from the United Kingdom. This “nasty neighbor” behavior is independent of in-group favoritism in trust and emerges when people perceive within-group resource scarcity. We discuss how to reconcile that humans exhibit nastiness and favoritism toward in-group members with existing theory on in-group favoritism.


Introduction
A variety of experimental games have been employed to identify ingroup favouritism (2,8).In its simplest form, a game involves two agents A and B each with a binary choice that is taken simultaneously and after which the game ends.Individual payoffs are a function of the combination of both agents' choices.As an example, consider the Prisoner's Dilemma (PD).In the two-player PD, each player must choose between an action often labelled as cooperation (C) and another action labelled defection (D).Each player benefits personally most from choosing D rather than C, and the unique pure Nash Equilibrium is reached when both players choose D. In equilibrium, however, each player earns less compared to when both had chosen C. In the PD, the C-C combination maximizes joint payout and is 'pareto efficient' (51), but is not an equilibrium of this game.Choosing D in the Prisoner's Dilemma is a dominant strategy.Ingroup favouritism is revealed as a stronger propensity to choose C than D when interacting with an ingroup rather than an outgroup member or stranger.

Attacker Defender Contest Game
The attacker defender contest (AD-C) is special case of a class of Tullock contest games that model competition, or 'rent-seeking' between individual and groups and has strong similarities to related games like tug-of-war and pre-emptive strike games (35,38,51,83).The contest has two players A (for attacker) and D (for defender) each with an endowment e from which they can invest x in a contest.As is typical for contest games, any investment is wasted.Similar to the Prisoner's dilemma game, there is a pareto efficient state where both agents do not invest anything (Attacker x A = Defender xD = 0).However, when investments in attack exceed those in defence (xA > xD), the attacker earns the non-invested resources from the Defender (e -xD) leading to a payoff of 2e -xA -xD; in this case the defender earns 0. In all other cases, where xA ≤ xD, attacker and defender earn their non-invested resources (i.e., e -xA and e -xD, respectively).For rational selfish players, the peaceful solution (xA = xD = 0) does not constitute a Nash equilibrium.When xD = 0, an Attacker should simply invest one unit (xA = 1) to win the conflict (in other words, xA = 0 is strictly dominated by xA = 1 in this case).Yet, if xA = 1, the Defender should respond with xD = 1, which then changes the optimal response of the Attacker to xA = 2.Note that because of these properties, the AD-C is an asymmetric game in that a player's incentives for a particular strategy change when they change roles (this is not the case in symmetric games like, e.g., the PD).
A formal analysis of the equilibrium properties of the AD-C reveal its Nash equilibrium in mixed strategies ( (35,84); Figure S1).Compared to the PD, there is no pure Nash equilibrium.With an equal starting endowment of e = 10 for attackers and defenders, we denote p(X) as the probability of investing X by attackers, and p(Y) the probability of investing Y by defenders.A strategy assigns a probability value for each possible action (i.e., investment).In equilibrium attackers should choose: p(X = 1) = 2/45, p(X) = p(X -1)*[(12 -X)/(10 -X)] for 2 ≤ X ≤ 6, p(X = 0) = 1 -[p(X = 1) +…p(X = 6)] = 0.4, p(X) = 0 for X ≥ 7 i.e.; P(0) = 0.4, P(1) = 0.0 � 4, P(2) = 0.0 � 5, P(3) ≈ 0.0714, P(4) ≈ 0.0952, P(5) = 0.1 � 3, P(6) = 0.20, P(7) = 0, P This means that, contrary to the PD, in the AD-C there is not a clearly advantageous action.The personal earnings from investing in conflict depend on the investments made by the opponent, and vice versa.The best-response of defenders is to match attackers' investments, whereas for attackers, the best response would be to invest exactly either one unit more than the defenders or to not invest in attack at all, depending on whether the remaining capital not invested by attackers and defenders is large enough to make an attack investment worthwhile.Ingroup favouritism in the AD-C would mean stronger conflict investment when interacting with an outgroup individual or stranger, than with an ingroup member.In sum, unlike the prisoner's dilemma, the attacker-defender game does not have a pure Nash equilibrium, and it is characterized asymmetric payoff functions for attacker and defender.
The equilibrium properties of the attacker-defender game allow to identify that rational, risk-neutral, expected payoff maximizing agents on average invest iatt = 2.62 in attack, and idef = 3.38 in defence.
Furthermore, we can identify that for rational payoff maximizing agents, i > 6 (with e = 10, as in the current studies) are out-of-equilibrium and should never be played.The mixed-strategy equilibrium of the attacker-defender contest implies that mean investments, across trials and with different opponents, emerge because of some mixing of investments (for the game-theoretic probabilities with which investments are played, see Figure S1 here above).In our studies 1, 3 and 4 (where, in contrast to Study 2, participants made a number of investment decisions and distributions can be meaningfully assessed), we indeed see that the average 'over-investment' in attack and defence emerges because out-of-equilibrium investments are played more than expected under the assumptions of rational payoff maximization (Figure S2.a to S2.c).
Recall that not investing at all in conflict, i att = idef = 0 is preserving social welfare and can be considered the maximally cooperative action to choose.Rational agents are expected to choose i = 0 sometimes and also in our studies, we observe i = 0 actions.However, both iatt and idef are above 0 more often than would have been expected under the assumptions of rationality.Moreover, and crucially, we observe i = 0 in equal proportions when individuals are paired with an opponent from their in-group, an out-group or with a stranger.This suggests that the nasty neighbour effect is not so much about whether someone competes (or cooperates), but rather about how much one invests in competing.We return to this when reporting the complementary 'tournament' study in section 5 here below.

Trust Game
In its standard form (85), the TG has two players, the investor (I) and the trustee (T), and involves two stages.In Stage 1, the investor decides how much out of endowment e to transfer to the trustee.Transfer x (with 0 ≤ x ≤ e) is tripled and, in Stage 2, the trustee decides how much to transfer back (y) to the investor (with y ≤ 3x).This ends the game, with the investor earning e -x + y, and the trustee earning 3x -y.Strict payoff maximizing, rational players in the TG should neither transfer (x = 0) nor back-transfer (y = 0).
Transfers are assumed to reflect how much the investor trusts the trustee.Back-transfers are assumed to reflect the trustee's generosity or concerns for reciprocity.Ingroup favouritism in the TG would manifest in larger transfers and/or back-transfers when interacting with an ingroup partner, than with an outgroup individual or stranger (2).Stronger ingroup favouritism in transfers reflect investors trusting and/or being more generous towards ingroup partners more than outgroup partners or strangers.Stronger ingroup favouritism in back-transfers reflect trustees are more generous towards ingroup partners compared to outgroup partners and strangers (15).

Nested-Social Dilemma
Like the classic prisoner's dilemma, the attacker-defender contest and trust game are so-called one-level games between two individuals.Ingroup favouritism has been examined also in two-level games, where individuals are nested in groups and groups are nested in an overarching collective (for a review, see (6)).
One example is the nested social dilemma (9, 17) (NSD).Individuals (e.g., 8) are organized in two groups of (usually) equal size, an ingroup and an outgroup, and are given an endowment e which they distribute at their own discretion across three pools -private, club, and universal.Allocations to private benefit the individual only and no one else (in our Study 5, one unit in private was simply worth 1 unit for payout).
Allocations to club benefit all ingroup members, the individual included, and no one else.In our Study 5, one unit in club returned 0.5 to each ingroup member, and 0 to outgroup members.Allocations to universal benefit all individuals in the in-and outgroup alike.In our Study 5, one unit in collective returned 0.5 to each individual in the in-and the outgroup.Contributions to club are sometimes referred to as parochial, or ingroup cooperation, and to universal as universal cooperation.
Because allocations to both club and universal are (equally) costly to the individual (i.e., their marginal return is lower than allocations to private), strict payoff maximizing agents in the NSD should allocate their entire e to private, and nothing to club or collective.Like the PD, the NSD thus has a single pure Nash equilibrium in choosing D (i.e., allocating all units to private).And like the PD, it is pareto efficient and collectively most beneficial to allocate the entire e to collective.Under the current parameters, allocating to club is intermediate between strict payoff maximization and pareto efficiency, and reflects ingroup favouritism.In the NSD, ingroup favouritism, among other things, maximizes ingroup welfare, increases

THE NASTY NEIGHBOUR EFFECT IN HUMANS
the probability that the ingroup emerges as wealthier than the outgroup, and prohibits that the ingroup is being 'exploited' by the outgroup.

Costly Punishment
Punishment, conditional on observed actions or outcomes, has been widely investigated in the social dilemma literature (e.g., (55)).In economic games, punishment is often operationalized as a costly action that a player can take to reduce the earnings of another player after observing their choice ('peer punishment').If punishment is costly for the punishing party, rational-selfish players should not dedicate any resources to punishment in one-shot games since punishment reduces own earnings.Nevertheless, peer punishment is often observed in the laboratory (55).In the NSD, ingroup favouritism in punishment (or attack) can be revealed by looking at the willingness to punish conditional on the outcome or earnings of the punished.If punishment choices differ for the same outcome depending on the group membership of the punished, it shows that punishment is not impartially used but influenced by what group the person belongs to ((18), 'parochial punishment').
Importantly, punishment can be employed to decrease or increase the gap between own earnings (after Stage 1) and others' earnings.Higher punishment towards ingroup or outgroup members can thus change the relative standing (in terms of earnings) within or between groups.

Humans as nasty neighbours 2.1 Study 1
The study comprised a total of 51 nations, and a sample size of 12,863 subjects.There was no specific screening for the selection for countries, other than trying to diversify the variability in terms of the economic, institutional, and cultural context as much as possible.We selected all countries that were available in the Toluna panel.The full list is presented on the following page.

Treatment effects.
First, we present the models with the main treatments: ingroup (vs outgroup & stranger) for both attack and defence.We excluded participants that did not responded correctly to the comprehension checks in their first attempt and that failed an attention check in which they were asked not to respond to a Likert-style question (~23%).The ingroup (vs outgroup & stranger) variable is a dummy variable with decisions with outgroup members and undefined strangers coded as 0, and decisions with ingroup members coded as 1.In these models, participants and countries were random intercepts.Contrary to our pre-registered hypotheses, we find that people invested more in attack and defence with opponents from the same country, compared to opponents from foreign (i.e., outgroup) countries and strangers (Table S2).Results remain the same even when we separately consider decisions with outgroup members (attack: In Table S2 we also show whether investments in attack or defence towards outgroup members differ from investments toward strangers.In the cooperation literature, such contrast is often used to disentangle whether parochial cooperation is driven by ingroup favouritism or outgroup derogation (15).However, given that we find that parochial competition does not occur in the first place, this contrast can no longer be interpreted in relation to the difference in competition between ingroup and others.Nonetheless, we find that people invest more in both attack and defence with opponents from outgroup countries compared to unidentified strangers.S2 is that people made several decisions with different outgroup members, and this might have affected our results.We run two different models to test the robustness of the nasty neighbour effect, and to shed more light on its pervasiveness.In one model, we added a random intercept for country of the opponent that considers the dependencies in the choices made with opponents of outgroup countries.This is a very conservative approach as our main hypothesis pertains to the effect of ingroup vs outgroup members, independently of stereotypes.Nonetheless, we find that even with such conservative specification, people still significantly invest more in attack and defence with ingroup members, than outgroup members and strangers (Table S3).

Table S3
Mixed-effect model of treatment effects on investment decisions.In the second alternative approach, we ran all possible regressions with investments in attack and defence predicted by the variable ingroup vs outgroupx and stranger, with x being one of the 50 outgroup countries.
We ran these regressions for all the 51 countries, giving a total of 2,550 regressions.Then, we compared the results of these regressions with the distribution of outputs of the same number of regressions where we randomly allocated subjects to the variable ingroup or outgroup/stranger (also known as permutation tests; shown on the left panels in Fig S3).As shown, the patterns between the random allocation (left) and our actual treatment (right) look quite different, with our actual treatment showing most of the estimates above 0 (indicating the presence of the nasty neighbour effect), and with most contrasts to be significant at 5% level (blue dots).Results do not meaningfully change if we only consider ingroup vs outgroupx differences (Fig S4).

Fig S3.
Distribution of significant p-values for attack (top panels) and defence (bottom panels) investments.Plot showing the direction and frequency of significant estimates for the ingroup vs outgroup/stranger dummy predicting attack investments, considering each country independently as a potential outgroup.On the left, distribution of the estimates when we randomly assign decisions into the ingroup or outgroup/stranger dummy variable.On the right, the actual distribution of the estimates is shown.

Fig S4. Distribution of significant p-values for attack (top panels) and defence (bottom panels) investments.
Plot showing the direction and frequency of significant estimates for the ingroup vs outgroup dummy predicting attack investments, considering each country independently as a potential outgroup.On the left, distribution of the estimates when we randomly assign decisions into the ingroup or outgroup dummy variable.On the right, the actual distribution of the estimates is shown.
Finally, in Table S4 we control for several factors that could affect the extent to which people invested in attack and defence toward ingroup members (vs outgroup members and strangers).We find that the main predictor remains significant: people invest more in competing with opponents from the same country, compared to opponents from outgroup countries and strangers.Overall, we find that the effect is independent of age, gender, and education (i.e., lack of significant interaction effects).Only for defence, we find a significant interaction between gender and the extent to which people discriminate between ingroup members and outgroup members/strangers.The difference in attack between ingroup vs outgroup/stranger is larger for women compared to men (but still significant for both men and women).
In line with results reported in previous research (78), men invested more resources in attack and defence than women, older people invested less than younger people, and people with higher education invested more in conflict than people with lower education.we find no evidence that greater investments in conflict with ingroup members (vs outgroup members and strangers) between countries are associated with prominent cross-societal factors (12,24) (globalization, GDP per capita, rule of law, government effectiveness, historical prevalence of pathogens, and patriotism, etc.) (Figure S3).Only GDP per capita is significantly associated with differences in attack investments between ingroup and outgroup & stranger (r = 0.29, p = 0.04).
Yet, we do find stronger variation in how people invested in within-group aggression between countries; that can also account for the nasty neighbour effect between countries.In particular, we found that betweencountry differences in aggression and defence toward ingroup members are negatively associated with wealth, quality of institutions, and egalitarian values and positively associated with hierarchical values.While these results are only exploratory, they fit with the insights on the potential mechanisms associated with the nasty neighbour effect in Study 2 to 5.

Figure S5
Bivariate correlations between prominent cross-societal factors and the nasty neighbour effect across societies (cells with an × indicate non-significant associations).

Instructions
In this section, we include the English version of the instructions of the attacker-defender game.Written instructions were distributed across several pages and followed by pictures to aid the understanding of the game.

Instruction of the attacker-defender game
Welcome to the study.This is a study about decision making.
The study involves participants from 51 countries around the world.
You will be asked to make decisions in several decision making tasks.
You will be paired with a different person in each decision making task.
Please read the instructions carefully because you have the possibility to earn Monetary Units based on your decisions and others' decisions.
Each Monetary Unit (MU) is worth ## when making decisions.
You will be asked to make decisions in several decision making tasks.
You will be paired with a different person in each decision making task.
In this task, you will make decisions in two roles : (1) PERSON A, (2) PERSON B.
Both PERSON A and PERSON B will receive 10 Monetary Units.
Each monetary unit is #.When you interact with a person from a different country, then the value of an MU will be based on the average amount of pay for 2.5 minutes of work in that country.So, an MU has the same value across all of the countries participating in this study.In this study, you and the other participants will be asked to make several decisions either as PERSON A or PERSON B. Each decision will be made with a partner from one of the countries participating in this study.
At the end of this study, we will randomly select one of your decisions, match this decision with a corresponding partner participating in this study, and pay you and the other person accordingly.
If you are selected to be PERSON A, you will be paired with a person that has been selected as a PERSON B and vice versa.

Trial rounds.
To make sure you have understood the instructions, please calculate the final earnings for the following, Each decision will be made with a partner from one of the countries participating in this study.
In the picture below, you can see an example of decision with a person from United States.
Please click below to start.

Study 2
Participants were recruited through the Busara Center for Behavioral Economics.Groups were selected based on the prevalence of these communities in Nairobi (Kikuyu, Luo, Kamba and Luhya).S6 shows results from models of the ingroup (vs outgroup & strangers) contrast predicting attack and defence decisions.We excluded participants that failed simple attention checks in the lab (~27%).We also control for the community pairing (see Methods).Again, we find no support for the parochial competition hypothesis.In line with the cross-cultural study, people invested more resources in defending against ingroup members, compared to outgroup members and strangers.When we explore whether investments in attack or defence towards outgroup members differ from investments toward strangers we find, contrary to the cross-cultural Study 1, no significant differences in attack and defence with opponents from outgroup communities, compared to unidentified strangers.The exclusions do not meaningfully affect the overall interpretation of the results: Participants still invest more in attacking and defending from ingroup than outgroup members and strangers, yet the effect of defence investments becomes not significant.

Table S6
Mixed-effect model of treatment effects on investment decisions.S7 shows results from models of the ingroup (vs outgroup & strangers) contrast predicting attack and defence decisions, and models with geographical and cultural distance predicting attack and defence investments.Since a very small fraction of participants failed to respond to our attention check (<3%), all participants were included in the analyses.Excluding participants who did not pass the attention check did not affect the results.In line with Study 1, we find that individuals invest more resources in both attack and defence towards ingroup members, compared to outgroup members and strangers.Moreover, as in Study 2, we find no significant differences in both attack and defence with opponents from outgroup countries compared to unidentified strangers.Finally, and in line with Study 1, we find that geographical and cultural distance are negatively associated with conflict, suggesting that people invest more resources in attack and defence when interacting with opponents from geographically and culturally closer countries than more distant countries (Table S8).Altogether, these results replicate and support the conclusions from our first two studies.

Table S7
Mixed-effect model of treatment effects on investment decisions.S9 shows the results from mixed effect models of decisions in the trust game and in the attacker-defender contest.In line with Study 3, all participants were included in the analyses.Only one participant did not pass the attention check.Excluding the participant who did not pass the attention check did not affect the results.We see that people trust ingroup members more than outgroup members and strangers, and return more resources when paired with ingroup members, compared to outgroup members and strangers.We also find, as in Study 1-3, that people invest more resources in attacking ingroup members than outgroup members and strangers.We do not replicate this treatment effect on defence investments, although the direction of the effect is in line with the nasty neighbour effect.

Table S9
Mixed-effect model of treatment effects on investment decisions.

Association between ingroup favouritism and nastiness.
In this section, we report the analyses regarding the relation between ingroup favouritism in the trust game and the nasty neighbour effect in the attacker-defender contest game.To do so, we calculated the difference between trust (return) toward the own country and trust (return) toward others and averaged these two indicators into one overall indicator of ingroup favouritism in cooperation.Likewise, we calculated the difference between attack (defence) towards the own country vs others and created a measure of overall (ingroup) nastiness by averaging nastiness in attack and defence.We found no evidence that ingroup favouritism and (ingroup) nastiness are correlated (t(298) = 0.392, p = 0.695).
Second, we show the relation between the aspects of ingroup favouritism and (ingroup) nastiness that are conceptually related (Main Text, Fig 2b and 2c).Whereas ingroup favouritism in trust and ingroup favouritism in return were positively and significantly associated (r = 0.425, p < .001) as well as nastiness in attack and defence (r = 0.33, p < .001),there is a positive but insignificant correlation between (ingroup) nastiness in defence and ingroup favouritism trust (r = 0.097, p = .093;Fig. 2

Re-analysis cross-cultural study from Romano et al. (2021)
In this section, we report a re-analyses of a cross-cultural dataset that contains data on national ingroup favouritism in cooperation in the prisoner's dilemma (12).In this cross-cultural study (N = 18,411, sample stratified by age, gender, and income), participants across 42 societies made several independent decisions to cooperate in a prisoner's dilemma with ingroup members (same nation), outgroup members (operationalized by an opponent extracted from a pool of 16 outgroup nations), and an unidentified stranger.
In this study, the authors found that, on average, people cooperated more with ingroup members, compared to outgroup members and strangers.
Yet, as results from Study 4 suggest that ingroup favouritism in cooperation and neighbour nastiness are independent behavioural strategies, we can expect substantial individual heterogeneity, with people being nasty neighbours even in situations where ingroup favouritism cooperation is typically observed.To run this individual heterogeneity analysis, we divided participants in three types.Ingroup favouring types were defined as people that invested more resources in cooperating with ingroup members, compared to outgroup members and strangers.Nasty neighbours types were defined as people that invested more resources in cooperating with outgroup members and strangers, than ingroup members.Neither ingroup favouring nor nasty types were defined as people that did not discriminate between ingroup, outgroup members, and strangers.
Overall, we found that 8577 individuals (48%) could be categorized as ingroup favouring, 5,736 individuals (32%) could be categorized as nasty neighbours, and 3174 individuals (20%) could be categorized as neither ingroup favouring nor nasty.The difference in proportion of types was statistically significant, X 2 (2) = 1986.4,p < .001.A pair-wise chi-square test, testing whether the proportion of nasty neighbours types was higher than the 'neither ingroup favouring nor nasty' types, was also significant (p < .001).In sum, results from the re-analysis reveal that (i) neighbour nastiness can also be observed in other experimental paradigms, such as the prisoner's dilemma game and that (ii) people can be classified as nasty neighbour or ingroup favouring in the same situation.

Moderators and mediators in Study 3
Table S10 shows results from independent interaction models between a moderator variable (see Methods) and the ingroup (vs outgroup & strangers) variable.In the previous analyses we did not find substantial differences in the observed patterns between attack and defence investments, and for the current analyses aggregated across both attack and defence.The only significant interaction in the model is perceived status within a group; people that self-report to have lower status in their nation are the ones that discriminate more in their conflict investments between ingroup vs outgroup members and strangers (also see Fig. 3a, Main Text).We also explored the role of potential mediators: expectations, perceived competition over scarce resources and perceived similarity.We assessed these measures for each country participating in the study and ran multilevel mediation models (with subjects as random intercepts) using the causal mediation package (86).While we find that all three measures can account for the effect of national membership on conflict (Table S11), perceived competition over scarce resources is the only variable that fully mediates this association and that explains the highest proportion of variance.Perceived competition over scarce resources was assessed by the following question: "Competition plays an important role within and across countries.At a global and local stage, individuals, companies, and governments compete for scarce resources, like access to natural resources, access to new technology, participation in the labour market, or transnational agreements that govern the rights and obligations of citizens from different countries.Such competition can directly or indirectly also influence your own well-being.Please rate below, how much you think your own well-being is influenced by competition with people from different countries (0 = not at all, 10 = very much)".Participants responded for all opponent countries, including their own country.The model with THE NASTY NEIGHBOUR EFFECT IN HUMANS perceived competition over scarce resources as mediator and the other variables as controls is the only model that fully explains the nasty neighbour effect and the only one that explains a significant proportion of mediation in a multi-level mediation model (Table S11).Neither perceived similarity nor expectations explain a significant proportion of the mediation, when controlling for the other mechanisms.Moreover, we also ran models that included interactions between beliefs, perceived competition, and similarity with group membership predicting conflict expenditure in the attacker defender game.The conclusions do not change if we treat all variables as moderators: only perceived ingroup status and perceived competition over scarce resources show a significant interaction predicting conflict investments towards ingroup (vs outgroup & stranger) members (i.e., expectations and similarity do not significantly interact with the nasty neighbour effect in the attacker-defender game).In summary, we find that perceived competition over scarce resources fully mediates the effect of national membership (ingroup vs outgroup/strangers) on conflict.This result sheds light on the potential mechanisms related to the nasty neighbour effect we observed.

National identity and perceived competition in Study 4
Table S12 shows how observed ingroup favouritism in the trust game and (ingroup) nastiness in the attacker-defender game were predicted by different psychological mechanisms.In line with research on ingroup favouritism, social identification was significantly associated with ingroup favouritism in trust and trustworthiness but was not related to the nasty neighbour effect in attack and defence.In contrast, differences in perceived competition toward ingroup vs outgroup members were significantly associated with the nasty neighbour effect in attack and defence but not with ingroup favouritism in trust and trustworthiness.

Table S12.
Independent regression models predicting ingroup favouritism in the trust game or the nasty neighbour effect in the attacker-defender game.

Study 5
In Study 5, our aim was to test whether we could observe the nasty neighbour effect in minimal groups by experimentally manipulating two mechanisms that emerged to be associated with the nasty neighbour effect: resource scarcity and status concerns.All participants were included in the analyses.Only one participant did not pass the attention check.Excluding the participant who did not pass the attention check did not affect the results.4.3.1.Within vs between group competition.We introduced two competitive treatments.In the betweengroup competition conditions (present vs absent), we expected people to become more parochial once the opportunity to compete for a bonus in Stage 1 was introduced (see Methods).Our treatment was successful in manipulating perceived competition with ingroup vs outgroup members, as people perceived a relative higher competition with outgroups compared to ingroup members when between-group competition was present (vs absent: Welch two-sample t-test, t(472.66)= -4.475,p < 0.001).Moreover, in line with our preregistered hypothesis, we find that people were more parochial (i.e., higher investments towards the group-exclusive club pool) when between-group competition was present, compared to when between group competition was absent (paired t-test, t(275) = 5.773, p < 0.001).In the between-group competition conditions, people also invested more resources to the parochial compared to the universal pool (paired ttest, t(275) = 4.694, p < 0.001).
In Study 5, we also aimed to implement within-group competition by adding the possibility to get a bonus in Stage 2. In the within-group competition present condition, people were informed that they would get a bonus if, at the end of the experiment, they would earn more than their group members (in the control condition, the bonus was randomly allocated).In line with Stage 1, the value of the bonus was relatively low (in stage 2 participants are endowed with 20 MU and could use 5 to punish).Hence, the payoff maximizing strategy would be to keep in Stage 1 and not punish in Stage 2. Contrary to the between-group competition condition, this treatment was not successful in increasing the relative perceived competition with ingroup vs outgroup members (Welch two-sample t-test, t(543.57)= -1.201,p = 0.231).We suspect that this failure to implement within-group competition (vs not) may be due to the competitive nature of Stage 1, some misunderstanding among participants about the allocation of the bonus in Stage 2, or the relatively low incentive to get an extra bonus.Indeed, we find that the within-group competition treatment was not significantly associated with the nasty neighbour effect in punishment (linear regression, b = -0.034,p = 0.489).In contrast, the nasty neighbour effect was observed among people who perceived higher competition with ingroup relative to outgroup members, regardless of the treatment (linear regression, b = 0.048, p < 0.001).Moreover, in our setting, high status more likely result by being selfish in Stage 1, while low status more likely result by being a co-operator in Stage 1.While we believe the possibility for this confound to be unlikely (because participants were not provided feedback after Stage 1), future research is needed to study the interplay between status and ingroup aggression in other settings.

Status differences.
In Stage 2, we manipulated the earning status of the target of attack.Participants could assign up to 5 MU as 'deduction points' to an ingroup member and to an outgroup member.
Deductions reduced the target's earnings at a 1 to 3 ratio.We operationalized member status in terms of their earnings relative to others in their group and in the outgroup, and elicited attack decisions in 11 possible scenarios.In five scenarios, the participant had lower earning status, in one they had equal status, and in five they had greater earning status.Looking at the general attack decisions by status, we found that, in general, people tend to attack more individuals with higher status (than lower status), and that was true for both ingroup (b = 0.30, p < .001)and outgroup members (b = 0.66, p < .001).
Across all conditions, we find a significant interaction between status of the target and group membership (see Table S13).In particular, from the Johnson Neymann plot shown in Figure S6, people were parochial in their attack (more attack to outgroup vs ingroup members) when the targets of their attack were high earning status individuals and were nasty neighbours (more attack to ingroup vs outgroup members) when the target of their punishment were low earning status individuals.In this study, we also included measures of beliefs for Stage 1 and 2. When replacing behaviour with beliefs, the results for both Stage 1 and 2 remain the same.

Table S13.
Independent mixed effect models with subjects as random intercept and the interaction between status of the target and group membership predicting punishment.starting with the 11 trials, participants were informed that they could decide to be paid according to two options: in the first option they competed with people that identified themselves as leftists, knowing that if they selected this option, they would be randomly paired with a person from the leftists group, and that they would receive 1 MU each time they are closer to the correct answer than this person.The second option was the same, except that in this case they would be compared with people that identified themselves as rightists.

Results
In Regarding self-selection into the tournament, we find that 39% of the participants decided to engage in the tournament with ingroup members and 61% of the participants decided to engage in the tournament with outgroup members (Xsquared = 14.52, p < .001).This higher fraction of people selecting into a tournament with outgroup members was not predicted by social identification (generalized linear model of ingroup vs outgroup frequency predicted by social identification: b = -0.005,p = 0.96).In fact, we found that this pattern was mostly explained by stereotypes of intelligence and skills -when excluding participants that did not select based on such stereotypes, the difference between self-selection into ingroup or outgroup competition indeed disappears (when participants did not consider the outgroup unintelligent: Xsquared = 1.07, p = 0.30; when they did not consider the outgroup unskilled: Xsquared = 0.04, p = 0.85).Accordingly, the preference for competing against an outgroup member likely results from a stereotypical belief that political outgroups are unintelligent and unskilled, rather than from ingroup favouritism in competition.Indeed, across the 11 trials we also checked whether people were more accurate in their dot estimation when competing with ingroup vs outgroup: we found no significant differences in competitive performance: t(262.97)= 0.899, p = .37.Furthermore, in previous studies that implemented an option where participants were indifferent to ingroup and outgroup members, such option was chosen by the majority of the participants (52).We conclude that these results support neither the nasty neighbour effect nor ingroup favouritism.
Relation between parochial generosity and self-selection into tournament.As a further test, we also checked whether ingroup favouritism in generosity could explain or was associated with self-selection in competition with outgroup members.If that was the case, we should see that people opting to compete with outgroup members were also the ones that give more to ingroup members in the dictator game.This was, however, not the case.Selecting to compete with an ingroup vs outgroup individuals did not predict differences in generosity between ingroup and outgroup members: t(249.86)= -1.19,p = 0.24).This provides additional support that self-selecting into competition was not driven by ingroup favouritism, and that competitive motivation can co-exist with ingroup favouritism.

Figure S2 .
Figure S2.Proportions of investments made for each possible investment level (0, 1, 2, … 10) when agents play in equilibrium (open bars), and when participants are paired with an ingroup member (solid bars), or an out-group member or stranger (dashed bars).(a) Study 1 for attack (left) and defence (right) with out-group and stranger combined; (b) Study 1 with out-group and strangers separated for attack (left) and defence (right); (c) Study 3 for attack (left) and defence (right); (d) Study 4 for attack (left) and defence (right).

2. 1 . 3 .
Geographical and cultural distance.In this section, we report the results on geographical and cultural distance.Such analyses can provide additional support that people are more competitive toward ingroup than outgroup members and strangers.Geographical bilateral distances measure city-level data to account for the geographic distribution of population inside each nation(41).Geographical distance is available for 225 countries and consists of the distance between two countries based on bilateral distances between the biggest cities of those two countries.Socio-psychological distance (or cultural distance) is a measure of the overall psychological differences between societies.To build this index, we retrieved bilateral cultural distances data from http://culturaldistance.com/ (all dimensions) or here.This indicator is calculated from data on beliefs, values and behaviours that people have about or associate with their own nation retrieved from the World Values Survey (two waves: 2005-2009; 2010-2014; for a complete report of the analytic strategy to calculate this indicator see(42)).The World Values Survey dataset is composed of 170,247 participants from 80 nations (which altogether covers 85% of the world population).The list of measures used to calculate the socio-psychological distances can be found here: https://michael.muthukrishna.com/cultural-distance-data/.
PERSON A: decides whether to challenge PERSON B to take his or her MU.PERSON B: decides whether to prevent PERSON A from taking his or her MU.PERSON A can challenge PERSON B by investing between 0 and 10 MU to the challenge pool (5 in this example).PERSON B gets to decide whether to invest between 0 and 10 MU to prevent PERSON A from taking his or her MU (2 MU in this example).The MU invested to challenge PERSON B are lost.However, if they surpass the MU PERSON B has assigned to stop the Challenge, PERSON A receives the MU of PERSON B that were not assigned to the Challenge pool.Hence, in this example, PERSON A will keep the 5 MU that PERSON A did not invest in the challenge pool plus 8 MU from PERSON B (PERSON B's remaining endowment: 10 MU -2 MU = 8 MU).Hence, PERSON B will lose all of his or her MU because PERSON B's investment in prevention was less than PERSON A's investment in challenge.However, if PERSON B assigns the same MU as PERSON A or more (6 in this example), PERSON A does not receive the remaining MU from PERSON B. In this case, PERSON A and PERSON B keep whatever they have left of their starting capital (in this example, 5 MU for PERSON A, and 4 MU for PERSON B).
hypothetical scenario: Remember: Both PERSON A and PERSON B begin the task with 10 MU You are PERSON A and decide to invest 4 MU to take MU from PERSON B. PERSON B invests 8 MU to prevent PERSON A (YOU) from taking your MU.Then, (choose one) YOU earn 4, PERSON B earns 8 YOU earn 8, PERSON B earns 0 YOU earn 6, PERSON B earns 2 YOU earn 14, PERSON B earns 6 YOU earn 16, PERSON B earns 0 To make sure you have understood the instructions, please calculate the final earnings for the following, hypothetical scenario: Remember: Both PERSON A and PERSON B begin the task with 10 MU You are PERSON B and decide to invest 1 MU to prevent PERSON A from taking your MU.PERSON A invests 3 MU to take MU from PERSON B (YOU).Then, (choose one) YOU earn 0, PERSON A earns 7 YOU earn 1, PERSON A earns 3 YOU earn 9, PERSON A earns 7 YOU earn 0, PERSON A earns 16 YOU earn 16, PERSON A earns 0 2.1.4.3 Decision blocks.(if participant was in the role of Person A) PLEASE NOTE: IN THE NEXT BLOCK YOU WILL BE ASKED TO MAKE DECISIONS IN THE ROLE OF: PERSON A PERSON A can challenge PERSON B by investing between 0 and 10 MU to the challenge pool.Each decision will be made with a partner from one of the countries participating in this study.In the picture below, you can see an example of decision with a person from United States.Please click below to start.(if participant was in the role of Person B) PLEASE NOTE: IN THE NEXT BLOCK YOU WILL BE ASKED TO MAKE DECISIONS IN THE ROLE OF: PERSON B PERSON B gets to decide whether to invest between 0 and 10 MU to prevent PERSON A from taking his or her MU.

)
Number of MU you invest to take MU from PERSON B Each Monetary Unit (MU) is ## Set the button to a number PLEASE NOTE: in the next page, you will make a decision with a different partner Number of MU you invest to prevent PERSON A from taking your MU Each Monetary Unit (MU) is 1 #### Set the button to a number , Main Text) and a positive yet insignificant correlation between nastiness in attack and parochial returns (r = 0.10, p = .082;Fig 2, Main Text).If parochial cooperation is the flip side of parochial competition, we should have seen negative (and arguably more substantial) correlations.

Figure S6 .
Figure S6.Status differences favour the emergence of within-group nastiness.Floodlight plot showing the regions of differences in status of the target of attack (x axis, standardized) for which the effect of ingroup vs outgroup (y axis) on attack becomes significant.The vertical lines in the floodlight plot show the exact values at which significance begins and ends.Blue lines indicate significance at 5% level.
With these game-theoretic 'benchmarks', we can conclude that in Study 1, people 'over-invested.'The mean investment in attack with in-group (out- group; strangers) is 5.70 (5.34; 5.09 MU), and the mean investment in defence with in-group (out-group; strange) is 5.71(5.42;5.27).

Table S2 Mixed
One potential concern related to the results of the main regression model presented in the manuscript and in Table -effect model of treatment effects on investment decisions.Tests are two-sided.N observations = 363,231; Nsubjects = 12,863, Ncountries = 51.Ingroup = 0, Outgroup & stranger = 1.

.2. Cross-societal models.
As already suggested by the little variation shown in Fig.1b(Main Text),

Table S5
shows results from independent models of geographical and cultural distance predicting attack and defence decisions, and geographical and cultural distance in the same model with GDP per capita as a control.Across independent models, and models controlling for GDP, results remain the same: people invest more resources in attack and defence with opponent from geographically or culturally closer countries, compared to opponents from more distant countries.Moreover, results remain robust even when removing the most distant countries (i.e., removing countries above the third quartile of geographical distance; attack: b = -0.096,p < .001,defence: b = -0.084,p < .001).That said, it is important to note that, although the effect of geographical distance seems robust, the study was not specifically designed to test for geographical distance and future research is warranted to more precisely test the relation between distance and competition.

The nasty neighbour effect emerges independent of ingroup favouritism 3.1. Study 4 3.1.1. Treatment effects. Table
Tests are two-sided.
Tests are twosided with N = 552.Results remain robust when applying Bonferroni correction for multiple hypotheses testing.